public class ConcreteIterator implements AbstractIterrator{

    private ConcreteAggregate concreteAggregate;

    private int cursor;

    public ConcreteIterator(ConcreteAggregate aggregate) {
        this.concreteAggregate=aggregate;
        cursor=aggregate.list.size();
    }

    @Override
    public void moveNext() {
        if(hasNext()){
            cursor++;
        }
    }

    @Override
    public void moveFirst() {
        while(cursor>0){
            cursor--;
        }
    }

    @Override
    public Object currentItem() {
        return this.concreteAggregate.list.get(cursor);
    }

    @Override
    public boolean hasNext() {
        if(cursor==this.concreteAggregate.list.size()){
            return false;
        }else{
            return true;
        }
    }

    @Override
    public void addObject(Object object) {
        this.concreteAggregate.add(object);

    }

    @Override
    public boolean removeObject(Object object) {
        this.concreteAggregate.remove(object);
        return false;
    }
}
